package org.jeeasy.system.modules.dict.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.dromara.autotable.annotation.mysql.MysqlTypeConstant;
import org.dromara.mpe.autotable.annotation.Column;
import org.dromara.mpe.autotable.annotation.Table;
import org.jeeasy.common.core.annotation.dict.Dict;
import org.jeeasy.common.core.base.BaseEntity;
import org.jeeasy.common.core.domain.vo.BaseTree;
import org.jeeasy.common.core.enums.BooleanEnum;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * 数据字典
 *
 * @author AlpsDDJ
 * @date 2020/11/23 10:50
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_dict", comment = "数据字典")
public class SysDict extends BaseEntity<SysDict> implements BaseTree<SysDict>, Serializable {

    public static final String TOP_ID = "0";

    @Serial
    private static final long serialVersionUID = 1L;

    @Column(comment = "上级ID", length = 24)
    private String parentId;

    @Column(comment = "字典名称", length = 32)
    private String dictName;

    @Column(comment = "字典值", length = 32)
    private String dictCode;

    @Column(comment = "字典类型", length = 1, type = MysqlTypeConstant.TINYINT)
    private Integer dictType;

    @Column(comment = "描述", length = 255)
    private String description;

    @Column(comment = "排序", length = 4, decimalLength = 2)
    private Double sortOrder;

    //    @Dict(dictEnum = EnableFlagEnum.class)
    @Column(comment = "启用标记", length = 1, type = MysqlTypeConstant.TINYINT)
    private Integer enableFlag;

    @Column(comment = "允许删除", length = 1, type = MysqlTypeConstant.TINYINT)
    @Dict(dictEnum = BooleanEnum.class)
    private Integer allowDelete;

    @Column(comment = "允许修改", length = 1, type = MysqlTypeConstant.TINYINT)
    @Dict(dictEnum = BooleanEnum.class)
    private Integer allowUpdate;

    @TableField(exist = false)
    private List<SysDict> children;

}
